<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@ page language="java" contentType="text/html; charset=gb2312"
    pageEncoding="gb2312"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Insert title here</title>
</head>
<body>
<% request.setCharacterEncoding("gb2312");
String u=request.getParameter("id");
String p=request.getParameter("pwd");
ResultSet rs=null;
PreparedStatement ps=null;
Connection conn=null;
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
conn=DriverManager.getConnection("jdbc:sqlserver://127.0.0.1:1433;DatabaseName=Stu","sa","123");
 ps=conn.prepareStatement("select * from username where sname=? and spwd=?");
ps.setString(1, u);
ps.setString(2, p);
 rs=ps.executeQuery();
if(rs.next()){
	response.sendRedirect("loginh.jsp");
	
}else{response.sendRedirect("login.jsp");}
}catch(Exception e){
	e.printStackTrace();
}finally{
	try{
		if(rs!=null) rs.close();
		if(ps!=null) ps.close();
		if(conn!=null) conn.close();
	}catch(Exception e1){
		e1.printStackTrace();
	}
}

%>

</body>
</html>